package com.dubbo.common.exception;


import com.dubbo.common.dtos.ResponseResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 全局异常处理类
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 业务异常
     * @param e
     * @return
     */
    @ExceptionHandler(CarServiceException.class)
    public ResponseResult handleCarServiceException(CarServiceException e){
        return new ResponseResult(e.getStatus(),e.getMessage());
    }


    /**
     * 系统异常
     */
    @ExceptionHandler(Exception.class)
    public ResponseResult handleException(Exception e){
        return new ResponseResult(500,"系统异常: "+e.getMessage());
    }

}
